//
//  UserInfoCell.m
//  Tang
//
//  Created by 352324497@qq.com on 15/12/8.
//  Copyright © 2015年 352324497@qq.com. All rights reserved.
//

#import "UserInfoCell.h"

@implementation UserInfoCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.selectionStyle = NO;
        self.avatar = [[UIImageView alloc]initWithFrame:CGRectMake(10 * Kx6, 20 * Kx6, 40 * Kx6, 40 * Kx6)];
        self.avatar.backgroundColor = [UIColor orangeColor];
        self.avatar.layer.masksToBounds = YES;
        self.avatar.layer.cornerRadius = 20 * Kx6;
        [self.contentView addSubview:_avatar];
        
        self.nickname = [[UILabel alloc]initWithFrame:CGRectMake(60 * Kx6, 20 * Kx6, KWidth / 2, 20 * Kx6)];
        //self.nickname.backgroundColor = [UIColor lightGrayColor];
        self.nickname.textColor = [UIColor orangeColor];
        self.nickname.font = [UIFont systemFontOfSize:14 * Kx6];
        [self.contentView addSubview:_nickname];
        
        self.timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(KWidth - 10 * Kx6 - (KWidth / 3), 20 * Kx6, KWidth / 3, 20 * Kx6)];
        //self.timeLabel.backgroundColor = [UIColor darkGrayColor];
        self.timeLabel.font = [UIFont systemFontOfSize:12 * Kx6];
        self.timeLabel.textColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_timeLabel];
        
        self.conent = [[UILabel alloc]initWithFrame:CGRectMake(60 * Kx6, 50 * Kx6, KWidth - 70 * Kx6, 20 * Kx6)];
        self.conent.numberOfLines = 0;
        //self.conent.backgroundColor = [UIColor blueColor];
        self.conent.textColor = [UIColor darkGrayColor];
        self.conent.font = [UIFont systemFontOfSize:16 *Kx6];
        [self.contentView addSubview:_conent];
    }
    return self;
}

-(void)setModel:(UserModel *)model
{
    _model = model;
    if (model != nil)
    {
        [self.avatar sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:[UIImage imageNamed:@"happy"]];
        self.nickname.text = model.username;
        self.timeLabel.text = model.time;
        self.conent.text = model.conent;
      CGFloat height = [CallTool heightForNSStringWithString:model.conent width:KWidth - 70 * Kx6 fontSize:16 * Kx6 space:6];
        self.conent.height = height;
    }
}
+(CGFloat)heightForCellWithModel:(UserModel *)model
{
    CGFloat height = [CallTool heightForNSStringWithString:model.conent width:KWidth - 70 * Kx6 fontSize:16 * Kx6 space:6];
    return 70 * Kx6 + height;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
